package src.lab03.Test06;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lenovo on 2017/12/12.
 */
public class test01 {public static void main(String[] args) {
    String path = "D:\\hello.txt";
    RandomAccessFile file = null;

    Map<String,Integer> map = new HashMap<>();

    try {
        file = new RandomAccessFile(path,"rw");
        String line = null;
        while((line = file.readLine()) != null){



            //先判断map中有没有这个key，没有直接将value赋值为1

            if (map.get(line) == null){

                map.put(line,1);

            }else {

                int value = map.get(line);
                value = value + 1;
                map.put(line,value);
                System.out.println(line+"   "+map.get(line));
            }

            if (map.get(line) == 1){
                System.out.println(line+ "    "+map.get(line));
            }
        }

        //map
            /*


             */


    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}
}


